home *** CD-ROM | disk | FTP | other *** search
- Path: uuneo.neosoft.com!usenet
- From: Wmatthew@lan-aces.com (W. Matthews)
- Newsgroups: comp.lang.c++
- Subject: Re: Can you explain this?
- Date: 11 Mar 1996 14:35:45 GMT
- Organization: LAN-ACES, Inc.
- Message-ID: <4i1do1$b7i@uuneo.neosoft.com>
- References: <4hjijm$370@dfw-ixnews1.ix.netcom.com>
- NNTP-Posting-Host: 198.65.178.8
- X-Newsreader: WinVN 0.92.5
-
- In article <4hjijm$370@dfw-ixnews1.ix.netcom.com>, yurif@ix.netcom.com (Yuri Finkelstein) says:
- >
- >Can anybody explain why this tiny piece of code doesn't work in CASE1
- >( linker error )? Or it's just MSVC 4.0 specific?
- >Any help will be appreciated.
- >//--------------------------------------------------------------------------------------
- >#define CASE1
- >//#define CASE2
- >//#define CASE3
- >
- >template <class T> void SetParam( T* pT, int a )
- >{
- > pT->m_a = a;
- >}
- >
- >class FOO
- >{
- >
- >#ifdef CASE3
- >public:
- >#endif
- > int m_a;
- >
- >#ifdef CASE1
- > friend void SetParam( FOO* pFOO, int a );
- >#endif
- >
- >public:
- > void Bar( int a ) { SetParam( this, a ); }
- >}
- >
- >int main()
- >{
- > FOO foo;
- > foo.Bar( 5 );
- > return 0;
- >}
- >------------------------------------------------
- >Yuri Finkelstein
- >(415) 389-0653 (home)
- >
- I did not see a reply to this, but, (and I may be wrong) don't you have to
- instantiate SetParam since you made a template?
- Please, if I'm wrong let me know.
- ______________________________________________
- |Wyatt Matthews: Tech Support Department |
- |WMATTHEW@LAN-ACES.COM -Internet- |
- |WMATTHEW.MHS@LAN-ACES -MHS- |
- |LAN-ACES Tech Support (713)890-9786 |
- |LAN-ACES BBS (713)890-9790 |
- |LAN-ACES Fax (713)890-9731 |
- |LAN-ACES Sales (713)890-9787 |
- ______________________________________________
-